<template>
  <div class="con">
    <header>
      <div class="left" @click="onClickLeft()">
        <van-icon name="arrow-left" />
        <p>返回</p>
      </div>
      <div class="center">
        <p>选择收获信息</p>
      </div>
      <div class="right"></div>
    </header>
    <main>
      <div class="main1" v-for="(item,i) in info" :key="i">
        <div class="top">
          <div class="left" @click="detailadress(item.aid)">
            <p>{{item.name}}</p>
            <p style="margin-left:10px;font-size:14px">{{item.tel}}</p>
          </div>
          <div class="right">
            <van-icon name="records" class="records" @click="edit(item.aid)" />
          </div>
        </div>
        <div class="bottom">
          <p>{{item.locality}} {{item.address}}</p>
        </div>
      </div>
    </main>
    <footer>
      <p @click="addadress">添加新地址</p>
    </footer>
  </div>
</template>

<script>
import * as api from "../../api/getproductlist";
export default {
  name: "Getinfo",
  data() {
    return {
      searchResult: [],
      info: [],
      aid: []
    };
  },
  methods: {
    onClickLeft(id) {
      this.$router.go(-1);
    },
    onSave() {
      this.$router.push("/order");
    },
    addadress() {
      this.$router.push("/adress");
    },
    //修改
    edit(id) {
      this.$router.push("/updateadress/" + id);
    },

    //order展示
    detailadress(aid) {
      if(typeof(this.$route.query.id)!='object'){
        this.$router.push({
        path: "/order",
        query: {
          id: this.$route.query.id,
          pnum: this.$route.query.pnum,
          aid: aid
        }
      });
      }else{
         this.$router.push({
        path: "/order",
        query: {
          id: this.$route.query.id,
          price: this.$route.query.price,
          aid: aid
        }
      })
      }
      
    },

    onDelete() {
      this.$toast("delete");
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: "黄龙万科中心",
            address: "杭州市西湖区"
          }
        ];
      } else {
        this.searchResult = [];
      }
    }
  },
  mounted() {
    let uid=this.$store.state.uids
    api.getaddress({ uid: uid }).then(res => {
      this.info = res.data.data;
    });
  }
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}
.con {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
header {
  height: 66px;
  display: flex;
  justify-content: space-between;
  padding: 0 10px;
  align-items: center;
  font-size: 14px;
  color: #333333;
}
header .left {
  display: flex;
  align-items: center;
}
header .left p {
  margin-left: 5px;
}
header .center p {
  font-size: 18px;
}
main {
  flex: 1;
  overflow: auto;
}
.main1 {
  height: 100px;
  background: #fffcf7;
  border-top: 1px solid #f4f3f1;
  padding: 0 15px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 14px;
}
.main1 .top {
  display: flex;
  justify-content: space-between;
}
.main1 .top .left {
  display: flex;
}
.main1 .top .left {
  font-size: 18px;
  color: #3e3d39;
}
.main1 .top .left span {
  width: 50px;
  height: 25px;
  background: #e5290c;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin-left: 10px;
}
main .bottom {
  margin-top: 10px;
}
.records {
  font-size: 20px;
}
footer {
  height: 46px;
  background: #f32f17;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: white;
}
</style>